/* SharePoint Console Project
 * Http://SharePointConsole.codeplex.com
 * Copyright Jean-Alain Baeyens (2009)
 * Software under Microsoft Reciprocal License (Ms-RL)
 */

using System;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.Office.Server.Search.Administration;
using Sharepoint.Console.Entities;

namespace Sharepoint.Console.Search
{
    public class SharepointHelper
    {

        public CrawledProperty GetCrawledProperty(Connection conn, string propertyName)
        {
            Schema spSchema = new Schema(SearchContext.GetContext(conn.Site));
            CategoryCollection categories = spSchema.AllCategories ;

            foreach (Category categ in categories)
            {
                foreach (CrawledProperty cprop in categ.GetAllCrawledProperties())
                {
                    if (cprop.Name == propertyName)
                    {
                        return cprop;
                    }
                }
            }
            return null;
        }
    }
}
